﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace Swin_e_mon_Forms
{
    public class Player: GameEntity
    {
        public Location InLocation;

        public Player()
            : base(new string[] {"Me", "My", "I", "Inventory"}, true)
        { }

        public override GameEntity LocateEntity(string id)
        {
            GameEntity result = base.LocateEntity(id);
            if (result == null)
                result = InLocation.LocateEntity(id);
            return result;
        }

        public string MoveVia(string id)
        {
            Path p = InLocation.LocatePath(id);
            return p.TakePath(this);
        }
    }

    [TestFixture]
    public class TestPlayer
    {
        [Test]
        public void ATestPlayer()
        {
            Location aNewLoc = new Location(new string[] { "A Place" });

            Player aPlayer = new Player();
            aPlayer.InLocation = aNewLoc;

            Item bag = new Item(new string[] { "Bag" }, true);
            Item pen = new Item(new string[] { "Pen" }, false);

            pen.Title = "A pen title.";
            bag.Title = "A bag title.";
            aNewLoc.Title = "Badass Land";
            aPlayer.Title = "Lelouch Vi Britannia";

            pen.Description = " pen desc";
            bag.Description = "bag desc";
            aNewLoc.Description = "This Location is Badass";
            aPlayer.Description = "Emperor";


            bag.Inventory.AddItem(pen);
            aNewLoc.Inventory.AddItem(bag);

            Assert.AreSame(aPlayer,aPlayer.LocateEntity("Inventory"));
            Assert.AreSame(aPlayer, aPlayer.LocateEntity("Me"));
            Assert.AreSame(bag, aPlayer.LocateEntity("bag"));
            Assert.IsNull(aPlayer.LocateEntity("pen"));
        }
    }
}
